package Reader;

import org.junit.jupiter.api.Test;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

public class BufferedReaderTest {

    public static void main(String[] args) {

    }

    @Test
    public void test() throws IOException {
        String filePath = "D:\\aaaa\\test.txt";
        //创建一个节点流
        FileReader fileReader = new FileReader(filePath);
        //创建一个包装流
        BufferedReader bufferedReader = new BufferedReader(fileReader);
        /*按行读取，可以理解为bufferedReader对fileReader的功能扩展
        返回null时表示读取完毕
         */
        String line;
        while((line = bufferedReader.readLine())!=null){
            System.out.println(line);
        }

        //关闭外层的bufferedReader流即可，低层的fileReader会自动关闭
        bufferedReader.close();
    }

}
